<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>arcTo()方法画弧线</title>
		<style type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			canvas {
				width: 500px;
				height: 500px;
				border: 2px solid blue;
			}
		</style>
	</head>
	<body>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>
	<script>
		window.onload = function(){
			let oCanvas = document.getElementById('canvas');
			
			console.dir(oCanvas);
			
			let oPen = oCanvas.getContext("2d");
			
			console.dir(oPen);
	
			creatRound(oPen,200,200,50,50,30);
			function creatRound(pen,width,height,x,y,r){
				pen.moveTo(x+r,y);
				pen.lineTo(x+width-r,y);
				pen.arcTo(x+width,y,x+width,y+r,r);
				pen.lineTo(x+width,y+height-r);
				pen.arcTo(x+width,y+height,x+width-r,y+height,r);
				pen.lineTo(x+r,y+height);
				pen.arcTo(x,y+height,x,y+height-r,r);
				pen.lineTo(x,y+r);
				pen.arcTo(x,y,x+r,y,r);
			}
			oPen.stroke();
				
		}
	</script>
</html>